x11: Fix handling of `RRScreenChangeNotify`/`RRNotify` events
authorIan Douglas Scott <idscott@system76.com>
Sat, 28 Aug 2021 00:57:01 +0000 (17:57 -0700)
committerIan Douglas Scott <idscott@system76.com>
Sat, 28 Aug 2021 01:07:39 +0000 (18:07 -0700)
commit9e5a501c73c0cc5492b490ab9975743f816f1982
treeafccab5727abbd7132b202615fd90327494b8b75
parent94c3f4d4fc878f6cf7b1a0dc0ba2e3df54b936fb
x11: Fix handling of `RRScreenChangeNotify`/`RRNotify` events

It seems these are sent with `xwindow` set to the root window, so this
was failing to find a surface and get the screen from that.

I'm not sure if there's a reason not to get the screen this way
elsewhere in the function, but it seems this should be correct.

This fixes the behavior of `gdk_x11_display_get_monitors()`, which
wasn't correctly changing when monitors were added or removed. For
instance, this python code was always showing the same number of
monitors when one was turned off and on, but updates correctly with this
change applied:

```python
import gi
gi.require_version("GLib", "2.0")
gi.require_version("Gdk", "4.0")
gi.require_version("Gtk", "4.0")
from gi.repository import GLib, Gdk, Gtk

def f():
    print(len(Gdk.Display.get_default().get_monitors()))
    return True
GLib.timeout_add_seconds(1, f)

GLib.MainLoop().run()
```
gdk/x11/gdkdisplay-x11.c